<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mobile-Agent: The Future of GUI Automation</title>
    
    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    
    <!-- AOS CSS -->
    <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">

    <style>
        :root {
            --primary-color: #00ddff;
            --secondary-color: #f72585;
            --bg-color: #02001a;
            --text-color: #e0e0e0;
            --text-secondary-color: #b0b0c0;
            --glass-bg: rgba(20, 20, 40, 0.6);
            --border-color: rgba(0, 221, 255, 0.3);
            --glow-color: rgba(0, 221, 255, 0.4);
        }

        html {
            scroll-behavior: smooth;
        }

        body {
            margin: 0;
            font-family: 'Roboto', sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            overflow-x: hidden;
        }

        /* --- Header --- */
        header {
            position: fixed;
            top: 0;
            width: 100%;
            z-index: 1000;
            padding: 15px 5%;
            box-sizing: border-box;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: rgba(2, 0, 26, 0.5);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--border-color);
            transform: translateY(-100%);
            transition: transform 0.5s ease-in-out;
        }

        header.visible {
            transform: translateY(0);
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 15px;
            text-decoration: none;
            color: var(--text-color);
            font-family: 'Orbitron', sans-serif;
            font-size: 1.5rem;
            text-shadow: 0 0 10px var(--glow-color);
        }

        .logo img {
            height: 40px;
        }

        nav {
            display: flex;
            align-items: center;
            gap: 30px;
        }

        nav ul {
            list-style: none;
            display: flex;
            gap: 30px;
            margin: 0;
            padding: 0;
        }

        nav a {
            color: var(--text-color);
            text-decoration: none;
            font-weight: 400;
            transition: color 0.3s, text-shadow 0.3s;
            position: relative;
            padding: 5px 0;
        }

        nav a::after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            background-color: var(--primary-color);
            transition: width 0.3s ease;
        }
        
        nav a:hover::after, nav a.active::after {
            width: 100%;
        }

        nav a:hover {
            color: var(--primary-color);
            text-shadow: 0 0 8px var(--glow-color);
        }

        .lang-switcher button {
            background: none;
            border: 1px solid var(--border-color);
            color: var(--text-color);
            padding: 6px 12px;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .lang-switcher button.active, .lang-switcher button:hover {
            background-color: var(--primary-color);
            color: var(--bg-color);
            border-color: var(--primary-color);
            box-shadow: 0 0 12px var(--glow-color);
        }

        .menu-toggle {
            display: none;
            font-size: 2rem;
            background: none;
            border: none;
            color: var(--text-color);
            cursor: pointer;
        }

        /* --- Hero Section --- */
        #hero {
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            position: relative;
        }

        #hero-canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }

        .hero-content {
            position: relative;
            z-index: 1;
            animation: fadeIn 2s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .hero-content h1 {
            font-family: 'Orbitron', sans-serif;
            font-size: 4rem;
            margin: 0;
            letter-spacing: 2px;
            color: #fff;
            text-shadow: 0 0 10px var(--glow-color), 0 0 20px var(--glow-color), 0 0 40px var(--secondary-color);
            animation: glitch 3s infinite alternate;
        }
        
        @keyframes glitch {
            0% { transform: skew(0.5deg, -0.2deg); text-shadow: 0 0 10px #00ddff, 0 0 20px #00ddff, -2px 2px 2px #f72585, 2px -2px 2px #4cc9f0; }
            20% { transform: skew(-0.2deg, 0.5deg); }
            40% { transform: skew(0.5deg, -0.2deg); }
            60% { transform: skew(-0.2deg, 0.5deg); }
            80% { transform: skew(0.5deg, -0.2deg); text-shadow: 0 0 10px #00ddff, 0 0 20px #00ddff, 2px -2px 2px #f72585, -2px 2px 2px #4cc9f0;}
            100% { transform: skew(-0.2deg, 0.5deg); }
        }


        .hero-content .subtitle {
            font-size: 1.5rem;
            color: var(--text-secondary-color);
            margin: 20px 0 40px;
        }

        .cta-buttons {
            display: flex;
            gap: 20px;
            justify-content: center;
        }

        .btn {
            padding: 14px 30px;
            text-decoration: none;
            border-radius: 50px;
            font-weight: 700;
            transition: all 0.4s ease;
            border: 2px solid transparent;
            position: relative;
            overflow: hidden;
        }

        .btn-primary {
            background-color: var(--primary-color);
            color: var(--bg-color);
        }

        .btn-primary:hover {
            background-color: transparent;
            color: var(--primary-color);
            border-color: var(--primary-color);
            box-shadow: 0 0 20px var(--glow-color);
        }

        .btn-secondary {
            background-color: transparent;
            color: var(--text-color);
            border: 2px solid var(--border-color);
        }

        .btn-secondary:hover {
            color: var(--primary-color);
            border-color: var(--primary-color);
            box-shadow: 0 0 20px var(--glow-color);
        }
        
        .scroll-down {
            position: absolute;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            animation: bounce 2s infinite;
        }

        .scroll-down svg {
            width: 30px;
            height: 30px;
            fill: var(--primary-color);
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
            40% { transform: translateY(-15px); }
            60% { transform: translateY(-7px); }
        }

        /* --- Main Content & Section Styling --- */
        #main-content {
            position: relative;
            z-index: 2;
            background-color: var(--bg-color);
        }
        
        section {
            padding: 100px 5%;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .section-title {
            font-family: 'Orbitron', sans-serif;
            text-align: center;
            font-size: 2.8rem;
            margin-bottom: 60px;
            color: #fff;
            text-shadow: 0 0 10px var(--glow-color);
        }

        /* --- Glassmorphism Card --- */
        .glass-card {
            background: var(--glass-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--border-color);
            border-radius: 15px;
            padding: 30px;
            position: relative;
            overflow: hidden;
            transition: transform 0.3s ease;
        }
        
        .glass-card:hover {
            transform: translateY(-10px);
        }

        .glass-card::before {
            content: '';
            position: absolute;
            width: 150px;
            height: 150%;
            top: -25%;
            left: -50px;
            background: conic-gradient(from 180deg at 50% 50%, #f7258500 0%, #00ddff 50%, #f7258500 100%);
            animation: rotate-border 4s linear infinite;
            opacity: 0;
            transition: opacity 0.4s ease;
        }

        .glass-card:hover::before {
            opacity: 1;
        }

        @keyframes rotate-border {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }
        
        .card-content {
            position: relative;
            z-index: 2;
        }

        /* --- Vision Section --- */
        #vision {
            text-align: center;
        }
        #vision p {
            font-size: 1.4rem;
            line-height: 1.8;
            max-width: 800px;
            margin: 0 auto;
            color: var(--text-secondary-color);
        }
        
        /* --- Showcase Section --- */
        .showcase-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 40px;
            align-items: center;
        }

        .showcase-item {
            margin-bottom: 50px;
        }
        
        .showcase-item:nth-child(even) .showcase-text {
            grid-column: 2;
            grid-row: 1;
            text-align: right;
        }
        
        .showcase-item:nth-child(even) .showcase-media {
            grid-column: 1;
            grid-row: 1;
        }
        
        .showcase-text h3 {
            font-family: 'Orbitron', sans-serif;
            color: var(--primary-color);
            font-size: 1.8rem;
        }
        
        .showcase-text p {
            color: var(--text-secondary-color);
            line-height: 1.6;
        }

        .showcase-media video {
            width: 100%;
            border-radius: 10px;
            border: 1px solid var(--border-color);
            box-shadow: 0 0 30px rgba(0, 221, 255, 0.1);
        }

        /* --- Publications Section --- */
        .timeline {
            position: relative;
            max-width: 900px;
            margin: 0 auto;
        }
        
        .timeline::after {
            content: '';
            position: absolute;
            width: 3px;
            background-color: var(--border-color);
            top: 0;
            bottom: 0;
            left: 50%;
            margin-left: -1.5px;
        }

        .timeline-item {
            padding: 10px 40px;
            position: relative;
            width: 50%;
            box-sizing: border-box;
        }

        .timeline-item.left {
            left: 0;
        }

        .timeline-item.right {
            left: 50%;
        }

        .timeline-item::after {
            content: '';
            position: absolute;
            width: 20px;
            height: 20px;
            right: -10px;
            top: 25px;
            background-color: var(--bg-color);
            border: 3px solid var(--primary-color);
            border-radius: 50%;
            z-index: 1;
            box-shadow: 0 0 10px var(--glow-color);
        }
        
        .timeline-item.right::after {
            left: -10px;
        }
        
        .timeline-content {
            text-align: right;
        }
        .timeline-item.right .timeline-content {
            text-align: left;
        }
        
        .timeline-content h3 {
            margin: 0 0 5px 0;
            font-size: 1.2rem;
            color: #fff;
        }
        
        .timeline-content p {
            margin: 0 0 10px 0;
            color: var(--text-secondary-color);
            font-size: 0.9rem;
        }

        .timeline-links a {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: bold;
            margin: 0 5px;
        }
        
        /* --- Get Started Section --- */
        #get-started {
            text-align: center;
        }

        /* --- Footer --- */
        footer {
            padding: 40px 20px;
            text-align: center;
            color: var(--text-secondary-color);
            border-top: 1px solid var(--border-color);
            font-size: 0.9rem;
        }
        footer a { color: var(--primary-color); }

        /* --- Language hiding logic --- */
        [data-lang="en"], [data-lang="zh"] { display: none; }

        /* --- Responsive Design --- */
        @media (max-width: 900px) {
            .timeline::after { left: 10px; }
            .timeline-item { width: 100%; padding-left: 50px; padding-right: 10px; }
            .timeline-item.left, .timeline-item.right { left: 0; }
            .timeline-item::after { left: 1px; }
            .timeline-content, .timeline-item.right .timeline-content { text-align: left; }
        }

        @media (max-width: 768px) {
            header { padding: 15px 3%; }
            .logo span { display: none; }
            nav ul {
                display: none;
                flex-direction: column;
                position: absolute;
                top: 70px; right: 0; left: 0;
                background: rgba(2, 0, 26, 0.9);
                padding: 20px 0;
            }
            nav ul.active { display: flex; }
            .menu-toggle { display: block; z-index: 1; }
            nav { gap: 15px; }

            .hero-content h1 { font-size: 2.5rem; }
            .hero-content .subtitle { font-size: 1.1rem; }

            .showcase-grid { grid-template-columns: 1fr; }
            .showcase-item:nth-child(even) .showcase-text,
            .showcase-item:nth-child(even) .showcase-media { grid-column: 1; grid-row: auto; text-align: left; }
            .showcase-item:nth-child(even) .showcase-media { margin-top: 20px; }
        }
    </style>
</head>
<body>
    <div id="hero">
        <div id="hero-canvas"></div>
        <div class="hero-content">
            <h1>Mobile-Agent</h1>
            <p class="subtitle" data-lang="en">Autonomous Agents for Any GUI.</p>
            <p class="subtitle" data-lang="zh">驾驭万千图形界面的自主智能体。</p>
            <div class="cta-buttons">
                <a href="https://github.com/X-PLUG/MobileAgent" target="_blank" class="btn btn-primary">
                    <span data-lang="en">Explore on GitHub</span>
                    <span data-lang="zh">探索 GitHub</span>
                </a>
                <a href="#showcase" class="btn btn-secondary">
                    <span data-lang="en">See Demos</span>
                    <span data-lang="zh">观看演示</span>
                </a>
            </div>
        </div>
        <a href="#main-content" class="scroll-down" aria-label="Scroll down">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 17.27L18.18 11.09L16.77 9.68L12 14.45L7.23 9.68L5.82 11.09L12 17.27ZM12 4C11.45 4 11 4.45 11 5V14.45L12.71 12.74L14.12 14.15L12 16.27L9.88 14.15L11.29 12.74L13 14.45V5C13 4.45 12.55 4 12 4Z" transform="scale(1, -1) translate(0, -21)"/><path d="M7.41,8.59L12,13.17l4.59-4.58L18,10l-6,6l-6-6L7.41,8.59z"/></svg>
        </a>
    </div>

    <header id="header">
        <a href="#" class="logo">
            <img src="assets/logo.png" alt="Mobile Agent Logo">
            <span>Mobile-Agent</span>
        </a>
        <nav>
            <ul id="nav-menu">
                <li><a href="#vision"><span data-lang="en">Vision</span><span data-lang="zh">愿景</span></a></li>
                <li><a href="#showcase"><span data-lang="en">Showcase</span><span data-lang="zh">演示</span></a></li>
                <li><a href="#publications"><span data-lang="en">Publications</span><span data-lang="zh">论文</span></a></li>
                <li><a href="#get-started"><span data-lang="en">Get Started</span><span data-lang="zh">开始</span></a></li>
            </ul>
            <div class="lang-switcher">
                <button id="lang-en-btn">EN</button>
                <button id="lang-zh-btn">中文</button>
            </div>
        </nav>
        <button class="menu-toggle" id="menu-toggle" aria-label="Toggle menu">☰</button>
    </header>

    <div id="main-content">
        <section id="vision">
            <div class="container" data-aos="fade-up">
                <h2 class="section-title"><span data-lang="en">Our Vision</span><span data-lang="zh">我们的愿景</span></h2>
                <p>
                    <span data-lang="en">We are building a new generation of autonomous agents capable of understanding and operating any graphical user interface (GUI), from mobile apps to desktop software. Mobile-Agent empowers AI to interact with the digital world just as humans do, unlocking unprecedented levels of automation and accessibility.</span>
                    <span data-lang="zh">我们正在构建新一代的自主智能体，它能够理解并操作从移动应用到桌面软件的任何图形用户界面(GUI)。Mobile-Agent 赋予 AI 像人类一样与数字世界互动的能力，从而开启前所未有的自动化与无障碍化新篇章。</span>
                </p>
            </div>
        </section>

        <section id="showcase">
            <div class="container">
                <h2 class="section-title"><span data-lang="en">Showcase</span><span data-lang="zh">功能展示</span></h2>
                <div class="showcase-grid">
                    <div class="showcase-item" data-aos="fade-right">
                        <div class="showcase-text">
                            <h3><span data-lang="en">Cross-Platform Control</span><span data-lang="zh">跨平台操控</span></h3>
                            <p>
                                <span data-lang="en">Mobile-Agent v3 seamlessly operates across mobile, web, and PC platforms. Here it's tasked to perform a complex, multi-step operation.</span>
                                <span data-lang="zh">Mobile-Agent v3 能够无缝地在移动、网页和PC平台之间执行操作。这里它正在执行一个复杂的多步骤任务。</span>
                            </p>
                        </div>
                    </div>
                     <div class="showcase-item" data-aos="fade-left">
                        <div class="showcase-media">
                            <video controls muted poster="assets/framework.png" src="https://github.com/user-attachments/assets/ec7defa1-e6c5-40d2-84bd-c54e26a3fcec"></video>
                        </div>
                    </div>
                    
                    <div class="showcase-item" data-aos="fade-left">
                         <div class="showcase-text">
                            <h3><span data-lang="en">Complex PC Tasks</span><span data-lang="zh">复杂的PC任务</span></h3>
                            <p>
                                <span data-lang="en">Watch as the agent creates a PowerPoint presentation from scratch, demonstrating its ability to use complex desktop software.</span>
                                <span data-lang="zh">观看智能体从零开始创建一个PowerPoint演示文稿，展示其使用复杂桌面软件的能力。</span>
                            </p>
                        </div>
                    </div>
                     <div class="showcase-item" data-aos="fade-right">
                        <div class="showcase-media">
                           <video controls muted poster="assets/series.png" src="https://github.com/user-attachments/assets/a978087a-717b-4c8a-9e50-9223dac019dd"></video>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <section id="publications">
            <div class="container">
                <h2 class="section-title"><span data-lang="en">Our Research</span><span data-lang="zh">学术成果</span></h2>
                <div class="timeline">
                    <div class="timeline-item left" data-aos="fade-right">
                        <div class="glass-card">
                            <div class="card-content timeline-content">
                                <h3>Mobile-Agent-v3 <small>(Preprint)</small></h3>
                                <p><span data-lang="en">The foundational model for versatile GUI automation.</span><span data-lang="zh">通用GUI自动化的基础模型。</span></p>
                                <div class="timeline-links">
                                    <a href="https://arxiv.org/abs/2508.15144" target="_blank">[Paper]</a>
                                    <a href="https://github.com/X-PLUG/MobileAgent/tree/main/Mobile-Agent-v3" target="_blank">[Code]</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="timeline-item right" data-aos="fade-left">
                        <div class="glass-card">
                            <div class="card-content timeline-content">
                                <h3>GUI-Critic-R1 <small>(Preprint)</small></h3>
                                <p><span data-lang="en">A novel method for pre-operative error diagnosis.</span><span data-lang="zh">一种新颖的操作前错误诊断方法。</span></p>
                                <div class="timeline-links">
                                    <a href="https://arxiv.org/abs/2506.04614" target="_blank">[Paper]</a>
                                    <a href="https://github.com/X-PLUG/MobileAgent/tree/main/GUI-Critic-R1" target="_blank">[Code]</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="timeline-item left" data-aos="fade-right">
                        <div class="glass-card">
                            <div class="card-content timeline-content">
                                <h3>PC-Agent <small>(ICLR 2025 Workshop)</small></h3>
                                <p><span data-lang="en">A hierarchical multi-agent framework for PC automation.</span><span data-lang="zh">用于PC自动化的分层多智能体框架。</span></p>
                                <div class="timeline-links">
                                    <a href="https://arxiv.org/abs/2502.14282" target="_blank">[Paper]</a>
                                    <a href="https://github.com/X-PLUG/MobileAgent/tree/main/PC-Agent" target="_blank">[Code]</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="timeline-item right" data-aos="fade-right">
                        <div class="glass-card">
                            <div class="card-content timeline-content">
                                <h3>Mobile-Agent-E <small>(NeurIPS 2025 Workshop Oral)</small></h3>
                                <p><span data-lang="en">Self-evolving mobile assistant for complex tasks.</span><span data-lang="zh">可自我进化的移动助手，用于执行复杂任务。</span></p>
                                <div class="timeline-links">
                                    <a href="https://arxiv.org/abs/2501.11733" target="_blank">[Paper]</a>
                                    <a href="https://github.com/X-PLUG/MobileAgent/tree/main/Mobile-Agent-E" target="_blank">[Code]</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="timeline-item left" data-aos="fade-left">
                        <div class="glass-card">
                             <div class="card-content timeline-content">
                                <h3>Mobile-Agent-v2 <small>(NeurIPS 2024)</small></h3>
                                <p><span data-lang="en">Effective navigation via multi-agent collaboration on mobile.</span><span data-lang="zh">通过多智能体协作在移动设备上实现高效导航。</span></p>
                                <div class="timeline-links">
                                    <a href="https://arxiv.org/abs/2406.01014" target="_blank">[Paper]</a>
                                    <a href="https://github.com/X-PLUG/MobileAgent/tree/main/Mobile-Agent-v2" target="_blank">[Code]</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="timeline-item right" data-aos="fade-left">
                        <div class="glass-card">
                             <div class="card-content timeline-content">
                                <h3>Mobile-Agent-v1 <small>(ICLR 2024 Workshop)</small></h3>
                                <p><span data-lang="en">Autonomous multi-modal mobile device agent with visual perception.</span><span data-lang="zh">具有视觉感知的自主多模式移动设备代理。</span></p>
                                <div class="timeline-links">
                                    <a href="https://arxiv.org/abs/2401.16158" target="_blank">[Paper]</a>
                                    <a href="https://github.com/X-PLUG/MobileAgent/tree/main/Mobile-Agent-v1" target="_blank">[Code]</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <section id="get-started">
            <div class="container" data-aos="zoom-in">
                <h2 class="section-title"><span data-lang="en">Join the Future</span><span data-lang="zh">加入未来</span></h2>
                <p style="text-align: center; max-width: 600px; margin: -40px auto 40px auto; color: var(--text-secondary-color);">
                    <span data-lang="en">Explore our code, contribute to the project, or build your own GUI agents. The journey starts here.</span>
                    <span data-lang="zh">探索我们的代码，为项目做出贡献，或构建您自己的GUI智能体。旅程从这里开始。</span>
                </p>
                <div class="cta-buttons">
                    <a href="https://github.com/X-PLUG/MobileAgent" target="_blank" class="btn btn-primary">
                        <span data-lang="en">Go to GitHub</span>
                        <span data-lang="zh">前往 GitHub</span>
                    </a>
                    <a href="#publications" class="btn btn-secondary">
                        <span data-lang="en">Read the Papers</span>
                        <span data-lang="zh">阅读论文</span>
                    </a>
                </div>
            </div>
        </section>

    </div>

    <footer>
        <div class="container">
            <p>© 2025 Mobile-Agent Authors. All Rights Reserved.</p>
            <p><span data-lang="en">Page designed with ❤️ for the</span><span data-lang="zh">为</span> <a href="https://github.com/X-PLUG/MobileAgent" target="_blank">Mobile-Agent</a> <span data-lang="en">project</span><span data-lang="zh">项目献上 ❤️ 设计</span>.</p>
        </div>
    </footer>

    <!-- JavaScript Libraries -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
    <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            
            // --- Vanta.js 3D Background ---
            VANTA.NET({
                el: "#hero-canvas",
                mouseControls: true,
                touchControls: true,
                gyroControls: false,
                minHeight: 200.00,
                minWidth: 200.00,
                scale: 1.00,
                scaleMobile: 1.00,
                color: '#00ddff', // Primary color
                backgroundColor: '#02001a', // BG color
                points: 12.00,
                maxDistance: 22.00,
                spacing: 18.00
            });
            
            // --- Language Switcher Logic ---
            const langButtons = {
                en: document.getElementById('lang-en-btn'),
                zh: document.getElementById('lang-zh-btn')
            };

            function setLanguage(lang) {
                document.querySelectorAll('[data-lang]').forEach(el => {
                    if (el.dataset.lang === lang) {
                        el.style.display = el.tagName === 'SPAN' ? 'inline' : 'block';
                    } else {
                        el.style.display = 'none';
                    }
                });
                
                Object.values(langButtons).forEach(btn => btn.classList.remove('active'));
                if (langButtons[lang]) {
                    langButtons[lang].classList.add('active');
                }
                
                localStorage.setItem('preferredLanguage', lang);
            }

            Object.keys(langButtons).forEach(lang => {
                langButtons[lang].addEventListener('click', () => setLanguage(lang));
            });

            // Initial language setup
            let preferredLanguage = localStorage.getItem('preferredLanguage');
            if (!preferredLanguage) {
                preferredLanguage = navigator.language.startsWith('zh') ? 'zh' : 'en';
            }
            setLanguage(preferredLanguage);
            
            // --- Animate On Scroll (AOS) Initialization ---
            AOS.init({
                once: true, // Animation happens only once
                duration: 800,
            });

            // --- Sticky Header Logic ---
            const header = document.getElementById('header');
            const heroSection = document.getElementById('hero');
            
            const observer = new IntersectionObserver(
                ([entry]) => {
                    header.classList.toggle('visible', !entry.isIntersecting);
                },
                { threshold: 0.1 }
            );

            if (heroSection) {
                 observer.observe(heroSection);
            } else {
                header.classList.add('visible');
            }


            // --- Responsive Navbar Toggle ---
            const menuToggle = document.getElementById('menu-toggle');
            const navMenu = document.getElementById('nav-menu');
            menuToggle.addEventListener('click', () => {
                navMenu.classList.toggle('active');
            });

            // --- Close mobile menu when a link is clicked ---
            document.querySelectorAll('#nav-menu a').forEach(link => {
                link.addEventListener('click', () => {
                    if (navMenu.classList.contains('active')) {
                        navMenu.classList.remove('active');
                    }
                });
            });
        });
    </script>
</body>
</html>
